#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2020-08-26 11:04 上午
# @Author  : yangdy
# @File    : 2020-08-26.17.电话号码的字母组合
# @Software: PyCharmCE
from tools.my_methods import *


class Solution:
    def letterCombinations(self, digits: str) -> List[str]:
        ans = []
        if not digits:
            return ans
        mm = {
            '2': 'abc', '3': 'def', '4': 'ghi',
            '5': 'jkl', '6': 'mno', '7': 'pqrs',
            '8': 'tuv', '9': 'wxyz'
        }

        def dfs(i, n, ss, ret):
            if i >= n:
                ans.append(ret)
                return
            ws = mm[ss[i]]
            for wi in ws:
                dfs(i+1, n, ss, ret+wi)

        dfs(0, len(digits), digits, '')
        return ans


questions = [
    ('23',),
]

work(questions, lambda q: Solution().letterCombinations(q[0]))
